// xp_gethash.h
// ------------
// Extended stored procedure DLL for returning the calling SQL users SQL hash.

#pragma once

// Required libs
#pragma comment(lib,"C:\\Program Files\\Microsoft SQL Server\\90\\SDK\\Lib\\x86\\opends60.lib")
//                      ^^ this is the default path - adjust as needed if yours differs ^^

#define WIN32_LEAN_AND_MEAN

#include <Windows.h>
#include <sqlext.h>
#include <tchar.h>
#ifndef UNICODE
#include <stdio.h>
#endif
#include <srv.h>

#define RESULTS_MAX_COL_SIZE	8000		// Max column size for results
#ifndef XP_NOERROR
#define XP_NOERROR				0			// Used for Sql_Send* functions
#endif
#ifndef XP_ERROR
#define XP_ERROR				1			// Used for Sql_Send* functions
#endif

#define	TACOS_RULE				1

// Globals
DWORD	dwTOTALROWS = 0;

// Exports
#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) ULONG __GetXpVersion();
	#ifdef __cplusplus
}
#endif

// Added for xp_loadlibrary() usage
#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) bool xp_gethashlib(SRV_PROC *srvproc, TCHAR* tcParameters);
	#ifdef __cplusplus
}
#endif

// Xsproc entry point
#ifdef __cplusplus
extern "C"
{
	#endif
	__declspec(dllexport) SRVRETCODE xp_gethash(SRV_PROC *srvproc);
	#ifdef __cplusplus
}
#endif

// Functions
SRVRETCODE SqlGetHash(SRV_PROC *srvproc);
SRVRETCODE Sql_SendMsg(SRV_PROC *srvproc,TCHAR* tczMsg);
SRVRETCODE Sql_SendErr(SRV_PROC *srvproc,TCHAR* tczMsg);
SRVRETCODE Sql_PrepRows(SRV_PROC *srvproc);
SRVRETCODE Sql_SendRow(SRV_PROC *srvproc,TCHAR* tczMsg);
SRVRETCODE Sql_RowsDone(SRV_PROC *srvproc);